package com.jeewms.www.tms.ui.itemview;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.jeewms.www.tms.R;
import com.jeewms.www.tms.bean.vm.DemoVm;
import com.jeewms.www.tms.bean.vm.wmi1entity;
import com.jeewms.www.tms.constance.ClassHolder;
import com.jeewms.www.tms.util.Logutil;
import com.jeewms.www.tms.util.StringUtil;
import com.jeewms.www.tms.util.UpdataUiUtil;
import com.zhy.android.percent.support.PercentLinearLayout;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by 13799 on 2018/8/5.
 */

public class DemoItemView {
    Context mContext;
    View mView;
    ViewHolder viewHolder;

    public DemoItemView(Context context) {
        mContext = context;
        mView = LayoutInflater.from(context).inflate(R.layout.item_demo, null);
        viewHolder = new ViewHolder(mView);
    }

    public View getmView() {
        return mView;
    }

    public void bind(DemoVm vm, int position, int type, String className) {
        //上架
        Logutil.print(className);
        viewHolder.llHold.setVisibility(View.VISIBLE);
        viewHolder.llHold2.setVisibility(View.GONE);
        if (className.equals(ClassHolder.SHANGJIA)){//"打码入库";
            UpdataUiUtil.getDefaul().setText(vm.getWmX2(), viewHolder.tvX1)//物料号
                    .setText(vm.getWmX3(), viewHolder.tvX2)//交接数量
                    .setText(vm.getWmX17(), viewHolder.tvX3);
                 //   .setText(vm.getWmX7(), viewHolder.tvX4);//待上架数量
          //  Logutil.print("打印书"+vm.getWmX7());
        }else   if(className.equals(ClassHolder.XIAJIA)){//"下架";
            UpdataUiUtil.getDefaul().setText(vm.getWmX2(), viewHolder.tvX1)
                    .setText(vm.getWmX3(), viewHolder.tvX2)
                    .setText(vm.getWmX17(), viewHolder.tvX3);
        } else if (className.equals(ClassHolder.CAIGOUTUIHUO)) {//="采购入库";
            UpdataUiUtil.getDefaul().setText(vm.getWmX2(), viewHolder.tvX1)
                   .setText(vm.getWmX4(), viewHolder.tvX2)
                    .setText(vm.getWmX3(), viewHolder.tvX3)
                    .setText(vm.getWmX17(), viewHolder.tvX4);
        }else if(className.equals(ClassHolder.YIKU2)){//"移库2";
            UpdataUiUtil.getDefaul().setText(vm.getWmX2(), viewHolder.tvX1)
                    .setText(vm.getWmX3(), viewHolder.tvX2)
                    .setText(vm.getWmX4(), viewHolder.tvX3)
                    .setText(vm.getWmX5(), viewHolder.tvX4);
        }else if(className.equals(ClassHolder.CHENGPINXIAJIA)){//"成品拣货";
            UpdataUiUtil.getDefaul().setText(vm.getWmX2(), viewHolder.tvX1)//物料号
                    .setText(vm.getWmX3(), viewHolder.tvX2) //发货数
                    .setText(vm.getWmX4(), viewHolder.tvX3)//建议储位
                    .setText(vm.getWmX17(), viewHolder.tvX4);//待下架数量.
        }else if(className.equals(ClassHolder.FAHUOXIAJIA)){//"电商发货";
            UpdataUiUtil.getDefaul().setText(vm.getWmX2(), viewHolder.tvX1)
                    .setText(vm.getWmX6(), viewHolder.tvX2)
                    .setText(vm.getWmX3(), viewHolder.tvX3)
                    .setText(vm.getWmX17(), viewHolder.tvX4);
        }else if(className.equals(ClassHolder.CHENGPINTUIHUO)){//"成品退货";
            UpdataUiUtil.getDefaul().setText(vm.getWmX2(), viewHolder.tvX1)//物料号
                    .setText(vm.getWmX3(), viewHolder.tvX2) //发货数
                    .setText(vm.getWmX6(), viewHolder.tvX3)//建议储位
                    .setText(vm.getWmX17(), viewHolder.tvX4);//待下架数量.
        }

        else if(className.equals(ClassHolder.JIT)){//"JIT发货";
            Logutil.print("jIT"+className);
            UpdataUiUtil.getDefaul().setText(vm.getWmX2(), viewHolder.tvX1)//物料号
                    .setText(vm.getWmX4(), viewHolder.tvX2) //发货数
                    .setText(vm.getWmX3(), viewHolder.tvX3)//建议储位
                    .setText(vm.getWmX17(), viewHolder.tvX4);//待下架数量.
        }




        else if(className.equals(ClassHolder.YLSJ)){//"预留上架";
            UpdataUiUtil.getDefaul().setText(vm.getWmX2(), viewHolder.tvX1)//物料号
                    .setText(vm.getWmX3(), viewHolder.tvX2) //发货数
                    .setText(vm.getWmX8(), viewHolder.tvX3)//建议储位
                    .setText(vm.getWmX17(), viewHolder.tvX4);//待下架数量.






        }









}

    public void bind(wmi1entity vm, int position, int type, String className) {
        //上架详情     //储位库存 详细信息
        viewHolder.llHold.setVisibility(View.GONE);
        viewHolder.llHold2.setVisibility(View.VISIBLE);
        viewHolder.tvX3.setVisibility(View.GONE);
        viewHolder.tvX4.setVisibility(View.GONE);
        UpdataUiUtil.getDefaul().setText(vm.getWmX1(), viewHolder.tv2X1)
                .setText(vm.getWmX2(), viewHolder.tv2X2);

    }

static class ViewHolder {
    @BindView(R.id.tv_x1)
    TextView tvX1;
    @BindView(R.id.tv_x2)
    TextView tvX2;
    @BindView(R.id.tv_x3)
    TextView tvX3;
    @BindView(R.id.tv_x4)
    TextView tvX4;
    @BindView(R.id.ll_hold)
    PercentLinearLayout llHold;
    @BindView(R.id.tv2_x1)
    TextView tv2X1;
    @BindView(R.id.tv2_x2)
    TextView tv2X2;
    @BindView(R.id.ll_hold2)
    PercentLinearLayout llHold2;

    ViewHolder(View view) {
        ButterKnife.bind(this, view);
    }
}
}
